%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Edited by Shu Jiang, 2011.
% ALL RIGHTS ARE RESERVED.
% mailto: shujiang@tamu.edu
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% calculate the slope from the hip to swing leg ankle
function ret = Knee2D_slope(xpos,ypos,zpos,sns_brk,StanceLegIndex)
%     humanData = getData(name,i);

StartPt = sns_brk(2);
EndPt = sns_brk(3);
% from heel strike to the other heel strike
%%


for i = 1:length(xpos.lknee)
    % right leg is the stance leg
    if StanceLegIndex == 1
        % non-stance slope
        ns_slope(i) = NonStanceSlope(xpos.lhip(i),ypos.lhip(i),...
            xpos.lankle_avg(i),ypos.lankle_avg(i));
    else
        % non-stance slope
        ns_slope(i) = NonStanceSlope(xpos.rhip(i),ypos.rhip(i),...
            xpos.rankle_avg(i),ypos.rankle_avg(i));
    end

end

ret.nsslope = ns_slope(StartPt:EndPt);

end

% use the angle_avg
function ret = NonStanceSlope(xhip,yhip,xankle,yankle)
  ret =   (xhip-xankle)/(yhip-yankle);
end
